<template>
    <div class="content">
        <el-button type="primary" round @click="router.go(-1)" class="btn">返回</el-button>
    <el-form :model="form" label-width="120px">
        <span class="teacher">发起人：杨老师</span>
        <el-form-item label="请假学生">
      <el-input v-model="form.name" />
    </el-form-item>
    <el-form-item label="请假类型">
      <el-select v-model="form.leavetype" placeholder="请选择请假类型">
        <el-option label="事假" value="事假" />
        <el-option label="病假" value="病假" />
      </el-select>
    </el-form-item>
    <div class="demo-date-picker">
    <el-form-item label="请假时间">
      <el-date-picker
        v-model="form.leavetime"
        type="date"
        placeholder="Pick a day"
      />
    </el-form-item>
    </div>
    <el-form-item label="请假事由">
      <el-input v-model="form.leavereason" type="textarea" />
    </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit()">Create</el-button>
        <el-button>Cancel</el-button>
      </el-form-item>
    </el-form>
    </div>
  </template>
  <script lang="ts" setup>
import { reactive ,ref} from 'vue'
import { useRouter } from 'vue-router'
//获取数据仓库
import {useStudentsleaveStore} from '../../../stores/Family-schoolInteractiongll/Studentsleave'
var $store = useStudentsleaveStore();
  // 获取路由对象
var router = useRouter()
  // do not use same name with ref
let form = reactive({
id:'@id',
// num:$store.leavelist.list.length+1,
name:'',
grade:'一年级二班',
leavetype:'',
leavetime:'',
leavereason:'',
promoter:'杨老师',
leavestatus:['已通过'],
})

const onSubmit = () => {
    if(form.name != ''&& form.leavetype !=''&& form.leavereason !=''){
    // 发送请求将内容插入列表中
    // console.log(form);
    // console.log('submit!')
    $store.leaveList_add(form)
    }else{
        alert('请填入要发布的内容信息')
    }
}
  // 日期选择器
const value1 = ref('')
const value2 = ref('')
// const leavetime = ref('')
// 下拉框
// const value = ref('')
// 日期选择定义
const shortcuts = [
  {
    text: 'Today',
    value: new Date(),
  },
  {
    text: 'Yesterday',
    value: () => {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24)
      return date
    },
  },
  {
    text: 'A week ago',
    value: () => {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
      return date
    },
  },
]

  </script>
<style scoped>
.demo-date-picker {
  display: flex;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
}
.demo-date-picker .block {
  padding: 30px 0;
  text-align: center;
  border-right: solid 1px var(--el-border-color);
  flex: 1;
}
.demo-date-picker .block:last-child {
  border-right: none;
}
.demo-date-picker .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}
.content{
    width: 1000px;
    margin: 0 auto;
}
span{
    margin: 10 20px;
}
.el-button{
    margin: 0 5px;
}
.leave{
    display: flex;
    justify-content: flex-end;
    margin: 5px 10px;
}
.teacher{
    height: 60px;
    line-height: 50px;
    margin:10px 0 20px 50px;
}
.checkleave{
    margin-left: 20px;
    font-size: 17px;
}
.btn{
    margin-left: 50px;
}
</style>